---
title: Hooks
description: How to integrate Ultracite with AI coding assistants through editor hooks.
---

Ultracite can automatically format and fix code after AI coding assistants make edits through editor hooks. This ensures all AI-generated code adheres to your project's standards without manual intervention.

The hooks work alongside Biome's linting and formatting. After an AI coding assistant edits a file, the hook automatically runs `npx ultracite fix` to format and fix auto-fixable linting issues. This dual approach ensures both intelligent code generation (through AI rules) and automated code quality (through hooks).

> **Note:** Hooks are separate from AI coding rules. The `--agents` flag configures AI coding rules, while the `--hooks` flag sets up automatic formatting after file edits.

## Setup

### Automatic Setup

When you run `npx ultracite init`, you'll be prompted to select which editor hooks you want to enable:

```bash
? Which agent hooks do you want to enable (optional)?
  ◯ Cursor
  ◯ Claude Code
```

This will create the relevant hook configuration file in your project directory.

### Manual Setup

If you want to manually set things up or add hooks after initialization, run:

```bash
npx ultracite init --hooks cursor,claude
```

Alternatively, you can manually create or edit the hook configuration files in your project directory and add the appropriate hook command.

## Supported Editors

| Editor      | Hook File Location          | Documentation                                                           |
| ----------- | --------------------------- | ----------------------------------------------------------------------- |
| Cursor      | `.cursor/hooks.json`        | [Cursor Hooks](https://cursor.com/docs/agent/hooks)                    |
| Claude Code | `.claude/settings.json`     | [Claude Code Hooks](https://docs.claude.com/en/docs/claude-code/hooks) |

## How It Works

1. **Automatic Execution**: After the AI agent edits a file, the hook automatically runs `npx ultracite fix`
2. **Code Formatting**: Ultracite formats the edited code according to your Biome configuration
3. **Linting Fixes**: Auto-fixable linting issues are resolved automatically
4. **Seamless Integration**: The process happens transparently without interrupting your workflow

## Benefits

Using Ultracite editor hooks provides several advantages:

- **Consistency**: All AI-generated code is automatically formatted to match your style
- **Quality**: Linting issues are fixed immediately after code generation
- **Efficiency**: No need to manually run formatters or linters after AI edits
- **Standards**: Ensures AI-generated code always adheres to project standards
- **Clean Commits**: Code is properly formatted before you even review it

## Customization

Ultracite intelligently merges with existing hook configurations:

- **Preserves existing hooks**: All existing hooks and their commands remain intact
- **Avoids duplicates**: If Ultracite is already configured, it won't be added again
- **Non-destructive**: Your existing hook configuration structure is maintained

You can also customize the hook behavior by modifying the hook configuration files directly if you need different formatting commands or additional post-edit actions.